# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: rudy.matela

pkgbase=z3
pkgname=('z3' 'python-z3-solver')
pkgver=4.12.1
_commit=3012293c35eadbfd73e5b94adbe50b0cc44ffb83
pkgrel=2
pkgdesc='High-performance theorem prover'
url='https://github.com/Z3Prover/z3'
arch=('loong64' 'x86_64')
license=('MIT')
makedepends=('git' 'glibc' 'cmake' 'ninja' 'python' 'python-setuptools' 'gcc-libs'
             'python-build' 'python-installer' 'python-wheel')
source=(git+https://github.com/Z3Prover/z3.git#commit=$_commit)
sha512sums=('SKIP')
b2sums=('SKIP')

build() {
  cd z3
  cmake \
    -Bbuild \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DZ3_LINK_TIME_OPTIMIZATION=1 \
    -DZ3_BUILD_PYTHON_BINDINGS=1 \
    -DPYTHON_EXECUTABLE=/usr/bin/python
  ninja -C build
}

package_z3() {
  depends=('glibc' 'gcc-libs')
  provides=('libz3' 'libz3.so')

  cd z3
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname
  rm -r "$pkgdir"/usr/lib/python*
}

package_python-z3-solver() {
  depends=('python' 'python-setuptools' 'z3')
  replaces=('python-z3')
  conflicts=('python-z3')

  cd z3
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname

  cd "$pkgdir"
  rm -r usr/include usr/bin usr/lib/{cmake,pkgconfig,lib*}
  python -m compileall -d /usr/lib "$pkgdir/usr/lib"
  python -O -m compileall -d /usr/lib "$pkgdir/usr/lib"
}

# vim: ts=2 sw=2 et:
